package com.lagou.config;


import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Datasource {


    @Value("${dbUrl}")
    private String dbUrl;
    @Value("${dbusername}")
    private String usename;
    @Value("${password}")
    private String password;
    @Value("${driverClassName}")
    private String driverClassName;
    @Value("${initialSize}")
    private int initialSize;

    @Bean("myDatasource")
    public DruidDataSource dataSource() {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(this.dbUrl);
        datasource.setUsername(this.usename);
        datasource.setPassword(this.password);
        datasource.setDriverClassName(this.driverClassName);
        datasource.setInitialSize(this.initialSize);
        return datasource;
    }

}
